﻿<!DOCTYPE HTML>
<html>
<head>
<!--<meta http-equiv="content-type" content="text/html;charset=UTF-8">-->
<!--<meta name="viewport" content="width=device-width, initial-scale=1.0" />-->

<title>pinusmusicVIP申请</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<link href="css/iconfont.css" rel="stylesheet" type="text/css" />
<link href="css/test.css" rel="stylesheet" type="text/css" />
	<script src="js/jquery-3.3.1.js"></script>

<script>
$(function (){
	$.post(
			//uri
			"/music/user/ListQuestion",
			//参数
			{},
			//回调函数
			function (data){
				console.log(data)
				var li="";

				for (var i = 0; i < data.music.length; i++) {
					console.log(data.music[i].musicpath)
					 li+='<li id="qu_0_'+i+'">\n' +
							'<div class="test_content_nr_tt">\n' +
							'<i>'+(i+1)+'</i><span>(20分)</span>\n' +
							'<audio controls="controls">\n' +
							'<source src="../'+data.music[i].musicpath+'" type="audio/mp3">\n' +
							'</audio>\n' +
							'<b class="icon iconfont">&#xe881;</b>\n' +
							'</div>\n' +
							'<div class="test_content_nr_main">\n' +
							'<ul>\n';
					for (var j in data.list[i]) {
						var char;
						if (j==0){
							char='A';
						}else if (j==1){
							char='B';
						}else if(j==2){
							char='C';
						}else {char='D';}
						var op=data.list[i][j];
						var option='<li class="option">\n' +
						'<input type="radio" class="radioOrCheck" value="'+op+'" name="answer'+i+'"\n' +
						'id="0_answer_'+(i+1)+'_option_'+(j+1)+'"\n' +
						'/>\n' +
						'<label for="0_answer_'+(i+1)+'_option_'+(j+1)+'">\n' +
						''+char+'.\n' +
						'<p class="ue" style="display: inline;">'+op+'</p>\n' +
						'</label>\n' +
						'</li>\n';
						li+=option;
					}

					li+=
							'\n' +
							'</ul>\n' +
							'</div>\n' +
							'</li>'
				}
				$("#questions").html(li);
			},"json"
	);
	$("#submit").click(function (){
		$.post(
				//uri
				"/music/user/submit",
				//参数
				$("#questionForm").serialize(),
				//回调函数
				function (data){

					if (data>=60){
						alert("得分："+data+"，恭喜你，通过测试，已发送邮件至邮箱，请前往激活");

					}
					else {
						alert("得分："+data+"，很遗憾，没有通过测试，请再接再厉");
						location.href="vip.html";
					}
				}
				,"json");
	})

})
</script>
</head>

<body>
	<div class="main">
		<!--nr start-->
		<div class="test_main">
			<div class="nr_left">
				<div class="test">
					<form action="" method="post" id="questionForm">
						<div class="test_title">
							<p class="test_time">
								<i class="icon iconfont"></i><b class="alt-1"></b>
							</p>
							<font><input type="button" name="test_jiaojuan" id="submit" value="交卷"></font>
						</div>
						
							<div class="test_content">
								<div class="test_content_title">
									<h2>听歌识曲</h2><span>播放歌曲，选择正确的歌名</span>
									<p>
										<span>共</span><i class="content_lit">5</i><span>题，</span><span>合计</span><i class="content_fs">100</i><span>分</span>

									</p>
								</div>
							</div>
							<div class="test_content_nr">
								<ul id="questions">
										<h1>正在生成问题.....</h1>


								</ul>
							</div>
						
					</form>
				</div>

			</div>
			<div class="nr_right">
				<div class="nr_rt_main">
					<div class="rt_nr1">
						<div class="rt_nr1_title">
							<h1>
								<i class="icon iconfont">&#xe692;</i>答题卡
							</h1>
							<p class="test_time">
								<i class="icon iconfont">&#xe6fb;</i><b class="alt-1"></b>
							</p>
						</div>
						
							<div class="rt_content">
								<div class="rt_content_tt">
									<h2>单选题</h2>
									<p>
										<span>共</span><i class="content_lit">5</i><span>题</span>
									</p>
								</div>
								<div class="rt_content_nr answerSheet">
									<ul>
										
											<li><a href="#qu_0_0">1</a></li>
										
											<li><a href="#qu_0_1">2</a></li>
										
											<li><a href="#qu_0_2">3</a></li>
										
											<li><a href="#qu_0_3">4</a></li>
										
											<li><a href="#qu_0_4">5</a></li>

										
									</ul>
								</div>
							</div>
						
					</div>

				</div>
			</div>
		</div>
		<!--nr end-->
		<div class="foot"></div>
	</div>

<!--	<script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>-->
<!--	<script src="js/jquery.easy-pie-chart.js"></script>-->
	<!--时间js-->
<!--	<script src="time/jquery.countdown.js"></script>-->
	<script>
		// window.jQuery(function($) {
		// 	"use strict";
		//
		// 	$('time').countDown({
		// 		with_separators : false
		// 	});
		// 	$('.alt-1').countDown({
		// 		css_class : 'countdown-alt-1'
		// 	});
		// 	$('.alt-2').countDown({
		// 		css_class : 'countdown-alt-2'
		// 	});
		//
		// });
		
		
		$(function() {
			$.post("/music/user/isLogin",{},function (data) {
				if (!data){
					alert("请登录！")
					location.href="userlogin.html"
				}
			});
			$('li.option label').click(function() {
			debugger;
				var examId = $(this).closest('.test_content_nr_main').closest('li').attr('id'); // 得到题目ID
				var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
				// 设置已答题
				if(!cardLi.hasClass('hasBeenAnswer')){
					cardLi.addClass('hasBeenAnswer');
				}

			});
		});
	</script>


</body>

</html>